<template>
  <div class="customerOverview-container">
    <div class="customerOverview-page">
      <el-card class="overview-card">
        <div slot="header" class="clearfix">
          <div>客户基本情况</div>
          <el-button type="text" style="float:right;margin-top:-33px;" size="small" @click="showInfo">修改</el-button>
        </div>
         <table class="progress-table" cellpadding="0" cellspacing="0" border="0" style="width:100%;margin-bottom:20px">
          <tr>
            <Td class="table-title" style="width:25%">法人</Td>
            <Td style="width:25%">{{info.legalPerson}}</Td>
            <Td class="table-title" style="width:25%">统一社会信用码</Td>
            <Td style="width:25%">{{info.businessCode}}</Td>
          </tr>
          <tr>
            <Td class="table-title" style="width:25%">客户行业</Td>
            <Td style="width:25%">{{info.customerNewIndustry}}</Td>
            <Td class="table-title" style="width:25%">客户状态</Td>
            <Td style="width:25%">{{info.customerState}}</Td>
          </tr>
          <tr>
            <Td class="table-title" style="width:25%">客户分类</Td>
            <Td style="width:25%">{{info.customerType}}</Td>
            <Td class="table-title" style="width:25%">客户性质</Td>
            <Td style="width:25%">{{info.customerQuality}}</Td>
          </tr>
          <tr>
            <Td class="table-title" style="width:25%">客户来源</Td>
            <Td style="width:25%">{{info.customerSource}}</Td>
            <Td class="table-title" style="width:25%">公司官网</Td>
            <Td style="width:25%">{{info.customerUrl}}</Td>
          </tr>
          <tr>
            <Td class="table-title" style="width:25%">所在地区</Td>
            <Td style="width:25%">{{info.areaInfo}}</Td>
            <Td class="table-title" style="width:25%">公司介绍</Td>
            <Td style="width:25%">{{info.customerDetail}}</Td>
          </tr>
          <tr>
            <Td class="table-title" style="width:25%">详细地址</Td>
            <Td style="width:25%">{{info.addressDetail}}</Td>
            <Td class="table-title" style="width:25%">经营范围</Td>
            <Td style="width:25%">{{info.businessInfo}}</Td>
          </tr>
        </table>
      </el-card>
      <el-card class="overview-card" style="margin-top:20px;">
        <div slot="header" class="clearfix">
          <div>收货信息</div>
        </div>
        <el-table :data="list" border style="width: 100%; margin-bottom: 20px">
          <el-table-column
            label="收货人"
            align="center"
            min-width="100">
            <template slot-scope="scope">
                {{scope.row.receiverName}}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="收货电话"
            min-width="150">
            <template slot-scope="scope">
              {{scope.row.receiverMobile}}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="收货地址"
            min-width="150">
            <template slot-scope="scope">
              {{scope.row.addressInfo}}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="最新收货时间"
            min-width="150">
            <template slot-scope="scope">

            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <el-card class="overview-card" style="margin-top:20px;">
        <div slot="header" class="clearfix">
          <div>开票信息</div>
          <el-button type="text" style="float:right;margin-top:-33px;" size="small" @click="showInvoicing">修改</el-button>
        </div>
        <table class="progress-table" cellpadding="0" cellspacing="0" border="0" style="width:100%;margin-bottom:20px">
          <tr>
            <Td class="table-title" style="width:25%">公司</Td>
            <Td style="width:25%">{{invoiceInfo.customerName}}</Td>
            <Td class="table-title" style="width:25%">社会统一信用码</Td>
            <Td style="width:25%">{{invoiceInfo.businessCode}}</Td>
          </tr>
          <tr>
            <Td class="table-title" style="width:25%">开户银行</Td>
            <Td style="width:25%">{{invoiceInfo.bankName}}</Td>
            <Td class="table-title" style="width:25%">开户帐号</Td>
            <Td style="width:25%">{{invoiceInfo.bankAccount}}</Td>
          </tr>
          <tr>
            <Td class="table-title" style="width:25%">公司地址</Td>
            <Td style="width:25%">{{invoiceInfo.addressInfo}}</Td>
            <Td class="table-title" style="width:25%">电话</Td>
            <Td style="width:25%">{{invoiceInfo.customerPhone}}</Td>
          </tr>
          <tr>
            <Td class="table-title" style="width:25%">收票信息</Td>
            <Td colspan="3">
              <span style="padding-right:10px;">{{invoiceInfo.receiverName}}</span>
              <span style="padding-right:10px;">{{invoiceInfo.receiverMobile}}</span>
              <span>{{invoiceInfo.receiverAddress}}</span>
            </Td>
          </tr>
        </table>
      </el-card>
    </div>

    <addCustomerInfo ref="addCustomerInfo" @getInfo="getInfo"></addCustomerInfo>
    <addInvoicing ref="addInvoicing" @getInvoiceInfo="getInvoiceInfo"></addInvoicing>

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import {formatDate} from '@/utils/date';
import store from '@/store'
import {getCustomerOption, addRelatio, delRelation,} from '@/api/partner'
import {customerNewBaseInfo,customerNewAddressList,developInvoiceInfo} from '@/api/company'
import addCustomerInfo from './addCustomerInfo'
import addInvoicing from './addInvoicing'

export default {
  name: "customerInfo",
  data(){
    return{
      roles:store.getters.roles ? store.getters.roles : [],
      list:[],
      list2:[],
      customerId:'',
      info:{},
      invoiceInfo:{}
    }
  },
  components : {
    addCustomerInfo,addInvoicing
  },
  computed: {
    ...mapGetters([
      'name',
      'mobile',
      'userId'
    ]),

  },
  created() {

  },
  filters: {

  },
  methods:{
    //获取开票信息
    getInvoiceInfo(){
      developInvoiceInfo({customerId:this.customerId}).then((res)=>{
        this.invoiceInfo = res;
      })
    },
    showInfo(){
       this.$refs.addCustomerInfo.showPop(this.info)
    },
    showInvoicing(){
      let data = JSON.parse(JSON.stringify(this.invoiceInfo));
      data.customerId = this.customerId
      this.$refs.addInvoicing.showPop(data)
    },
    init(customerId){
      this.customerId = customerId;
      this.getInfo();
      this.getAddressList();
      this.getInvoiceInfo();
    },
    //获取客户基本信息
    getInfo(){
      customerNewBaseInfo({customerId:this.customerId}).then((res)=>{
        this.info = res
      })
    },

    //获取客户收货信息
    getAddressList(){
      customerNewAddressList({customerId:this.customerId}).then((res)=>{
        this.list = res
      })
    },

  }
}
</script>

<style lang="scss">
.customerOverview-page{
  .overview-card .el-card__header{
    padding:10px 20px;
    line-height: 40px;
  }
}

</style>
